package com.jhh.pay.weishenma.service.impl;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;

import org.springframework.stereotype.Component;

import com.jhh.pay.weishenma.service.BankService;

@Component
public class BankServiceImpl implements BankService {
	
	private final HashMap<String, String> payToChannel;
	
	private final HashMap<String, String> channelToPay;
	
	public BankServiceImpl() {
		payToChannel = new HashMap<>();
		channelToPay = reverse(payToChannel);
	}
	
	public <K, V> HashMap<V, K> reverse(HashMap<K, V> originalMap) {  
	    HashMap<V, K> reverseMap = new HashMap<V, K>();  
	    Set<Entry<K,V>> set = originalMap.entrySet();  
	    Iterator<Entry<K,V>> it = set.iterator();  
	    while (it.hasNext()) {  
	        Entry<K,V> entry = it.next();  
	        reverseMap.put(entry.getValue(), entry.getKey());  
	    }  
	    return reverseMap;  
	}

}
